﻿#Include ..\..\_lib\ScrollGui.ahk


class ExtraArea {

  __New(hParent, child) {
    this.maxH := maxMsg * OutputGui.lineH - 20
    sg := ScrollGUI(child.Hwnd, 0, 0, '-Caption -Resize', 1, 1)
    sg.container.Opt('+Parent' hParent)

    DllCall('SetParent', 'ptr', sg.container.Hwnd, 'ptr', hParent)
    this.sg := sg, this.child := child
  }

  Show(x, y, options) {
    this.sg.Show('', Format('x{} y{} {}', x, y, options))
    this._HideScrollBar()
  }

  Hide() {
    this.sg.container.Hide()
  }

  Resume() {
    this.sg.container.Restore()
  }

  _HideScrollBar() {
    WinSetRegion('0-0 w320 h' this.maxH - 20, this.sg.container)
  }

  _ShowScrollBar() {
    WinSetRegion(, this.sg.container)
  }

  ScrollToTop() {
    while this.sg.PosV > 1
      SendMessage(0x0115, 4, 0, this.sg.container)
  }

  ScrollToBottom() {
    while this.sg.MaxV - this.sg.PageV + 1 > this.sg.PosV
      SendMessage(0x0115, 3, 0, this.sg.container)
  }

  Destroy() {
    this.sg.Destroy()
  }

}
